package com.salinity.kun.task;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import com.salinity.kun.helper.ComparisonHelper;
import com.salinity.kun.helper.ConstantHelper;
import com.salinity.kun.model.ComparisonContent;

public class ComparisonTask implements ITask {

	@Override
	public boolean run() throws IOException, ParseException {

		SimpleDateFormat sdf = ConstantHelper.getDateFormat();
		String startDateStr = ConstantHelper.getStartDate();
		String endDateStr = ConstantHelper.getEndDate();
		double T = ConstantHelper.getT0();
		double deltaT = ConstantHelper.getDT();
		int seriesCount = ConstantHelper.getSeriesCount();
		ComparisonContent[] comparisonContents =  ComparisonHelper.
				getComparisonContentFromFile(sdf.parse(startDateStr),
						sdf.parse(endDateStr), T, deltaT, seriesCount);
		
		ComparisonHelper.writeToFile(comparisonContents, ConstantHelper.getComparisonPath()
				.resolve(ConstantHelper.getComparisonFilename()));
		return false;
	}
	
	public static void main(String[] args) {
		ITask ComparisonTask = new ComparisonTask();
		try {
			ComparisonTask.run();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
